define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'pagearticle/index',
                    add_url: '',
                    edit_url: 'pagearticle/edit',
                    del_url: '',
                    multi_url: 'pagearticle/multi',
                    table: 'article_cate',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'name', title: __('Name')},
                        //{field: 'type_text', title: __('Type'), operate:false},
                        //{field: 'nid', title: __('Nid')},
                        //{field: 'sort', title: __('Sort')},
                        //{field: 'pid', title: __('Pid')},
                        //{field: 'path', title: __('Path')},
                        //{field: 'path_order', title: __('Path_order')},
                        //{field: 'input_time', title: __('Input_time')},
                        //{field: 'jumpurl', title: __('Jumpurl'), formatter: Table.api.formatter.url},
                        //{field: 'module_type_text', title: __('Module_type'), operate:false},
                        //{field: 'is_open_text', title: __('Is_open'), operate:false},
                        //{field: 'is_open1_text', title: __('Is_open1'), operate:false},
                        {field: 'operate', title: __('Operate'), events: Controller.api.events.operate, formatter: function (value, row, index) {

                            return  Table.api.formatter.operate.call(this, value, row, index, table);
                        }}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            },
            events: {//绑定事件的方法

                operate: $.extend({

                }, Table.api.events.operate)
            }
        }
    };
    return Controller;
});